﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using LibKetoan;

namespace Ketoan
{
	/// <summary>
	/// Summary description for TestForm.
	/// </summary>
	public class frmThumuc : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.Panel panel1;
		private FolderTreeView treeView1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox thumuc;
		private System.Windows.Forms.Button butOk;
		private System.Windows.Forms.Button butKetthuc;
		private System.ComponentModel.IContainer components=null;
		private AccessData d=new AccessData();
		public string s_dir,s_mmyy;
		private int i_loai,i_nhom;

		public frmThumuc(string s,string title,int loai,int nhom,string mmyy)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			this.thumuc.Text=s;
			this.Text=title;
			i_loai=loai;
			i_nhom=nhom;s_mmyy=mmyy;
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmThumuc));
			this.panel1 = new System.Windows.Forms.Panel();
			this.thumuc = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.butOk = new System.Windows.Forms.Button();
			this.butKetthuc = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Location = new System.Drawing.Point(8, 8);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(336, 290);
			this.panel1.TabIndex = 1;
			// 
			// thumuc
			// 
			this.thumuc.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.thumuc.BackColor = System.Drawing.SystemColors.HighlightText;
			this.thumuc.Enabled = false;
			this.thumuc.Location = new System.Drawing.Point(64, 301);
			this.thumuc.Name = "thumuc";
			this.thumuc.Size = new System.Drawing.Size(280, 20);
			this.thumuc.TabIndex = 5;
			this.thumuc.Text = "";
			// 
			// label2
			// 
			this.label2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.label2.Location = new System.Drawing.Point(8, 301);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(64, 23);
			this.label2.TabIndex = 4;
			this.label2.Text = "Thư mục :";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// butOk
			// 
			this.butOk.Image = ((System.Drawing.Bitmap)(resources.GetObject("butOk.Image")));
			this.butOk.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butOk.Location = new System.Drawing.Point(106, 332);
			this.butOk.Name = "butOk";
			this.butOk.Size = new System.Drawing.Size(68, 25);
			this.butOk.TabIndex = 6;
			this.butOk.Text = "      &Chọn";
			this.butOk.Click += new System.EventHandler(this.butOk_Click);
			// 
			// butKetthuc
			// 
			this.butKetthuc.Image = ((System.Drawing.Bitmap)(resources.GetObject("butKetthuc.Image")));
			this.butKetthuc.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butKetthuc.Location = new System.Drawing.Point(178, 332);
			this.butKetthuc.Name = "butKetthuc";
			this.butKetthuc.Size = new System.Drawing.Size(68, 25);
			this.butKetthuc.TabIndex = 7;
			this.butKetthuc.Text = "&Kết thúc";
			this.butKetthuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.butKetthuc.Click += new System.EventHandler(this.butKetthuc_Click);
			// 
			// frmThumuc
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(352, 373);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.butKetthuc,
																		  this.butOk,
																		  this.thumuc,
																		  this.label2,
																		  this.panel1});
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "frmThumuc";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Chọn thư mục";
			this.Load += new System.EventHandler(this.frmThumuc_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			this.thumuc.Text = this.treeView1.GetSelectedNodePath();
		}

		private void frmThumuc_Load(object sender, System.EventArgs e)
		{
			this.treeView1.InitFolderTreeView();
			bool folderFound = treeView1.DrillToFolder(this.thumuc.Text);
		}

		private void butKetthuc_Click(object sender, System.EventArgs e)
		{
			s_dir="";
			this.Close();
		}

		private void butOk_Click(object sender, System.EventArgs e)
		{
			s_dir=this.thumuc.Text;
			this.Close();
		}
	}
}
